package com.ls.fw.index.solr.client.dao.base;

import java.util.Map;

import net.semanticmetadata.lire.constant.FeatureField;

import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
import org.apache.solr.client.solrj.response.UpdateResponse;

import com.ls.fw.common.beanparser.bean.PageBean;
import com.ls.fw.common.beanparser.schema.Table;
import com.ls.fw.index.solr.client.exception.IndexSolrException;


/**
 * 
 * 注:
 *   若本接口的方法不能满足您的需求，可调用getServer方法操作底层方法
 * @see HttpSolrServer
 * @author defender
 *
 */
public interface BaseIndexSolrDao {

	/**
	 * 唯一键
	 */
	public static final String DEFAULT_PK = "id";
	
	
	public UpdateResponse add(Map<String, Object> data) throws IndexSolrException;
	
	public UpdateResponse add(Object model) throws IndexSolrException;
	
	public UpdateResponse save(Object model) throws IndexSolrException;
	
	public void createTable(Table table) throws IndexSolrException;
	
	public Table getTable(String table) throws IndexSolrException;
	
	public void deleteTable(String table) throws IndexSolrException;
	
	
	public void updateTable(Table table) throws IndexSolrException;

	
	/**
	 * 
	 * @param baseUrl
	 * @param name
	 * @return
	 */
	public SolrServer buildSolrServer(String baseUrlOrzkHost, String name);
	
	
	/**
	 * 
	 * @param baseUrl
	 * @param name
	 * @return
	 */
	public SolrServer newSolrServer(String baseUrlOrzkHost, String name);
	
	
	/**
	 * 改变collection
	 * @param name
	 */
	public SolrServer switchName(String name);
	
	
	/**
	 * 改变solr服务地址
	 * @param baseUrl
	 * @param name collection名称
	 * @return
	 */
	public SolrServer switchServer(String baseUrlOrzkHost,String name);
	
	
	/**
	 * 改变solr服务地址
	 * @param baseUrl
	 * @return
	 */
	public SolrServer switchServer(String baseUrlOrzkHost);
	
	public void commit() throws IndexSolrException;
	
	public void rollback() throws IndexSolrException;
	
	public SolrServer open()throws IndexSolrException;
	
	public SolrServer reopen()throws IndexSolrException;
	
	public void close() throws IndexSolrException;
	
	public SolrServer getServer();
	
	public String getBaseURL();
	 
	public String getName();
	
	public boolean isAutoCommit();
	
	public boolean isCloud();
	
	/**
	 * 添加图片索引
	 * @author ls 2014-8-18 下午03:10:46
	 * @param img
	 * @param path
	 * @param name
	 * @throws MyException
	 */
	public void addImage(BufferedImage img,String id,String path,String name) throws IndexSolrException;
	
	public void addImage(URL url,String id,String path,String name) throws IndexSolrException;
	
	public void addImage(BufferedImage img,String id,String path,String name,Map<String,Object> fields) throws IndexSolrException;
	
	public PageBean queryImage(URL url,int page,int pageSize) throws IndexSolrException;
	
	public PageBean queryImage(URL url,int page,int pageSize,FeatureField field) throws IndexSolrException;
}
